#include <REGX52.h>
#include "LCD1602.h"
#include "DS18B20.h"
#include "Delay.h"

float Temp;

void main()
{
	DS18B20_ConventT();//开启温度转化
	Delayms(1000);
	LCD_Init();
	LCD_ShowString(1, 1, "Temperature:");
    while(1)
    {
		DS18B20_ConventT();
        Temp = DS18B20_ReadT();//读取温度
		if(Temp < 0)
		{
			LCD_ShowChar(2, 1, '-');
			Temp = -Temp;
		}
		else
			LCD_ShowChar(2, 1, '+');
		LCD_ShowNum(2, 2, Temp, 3);//整数部分
		LCD_ShowChar(2, 5, '.');
		LCD_ShowNum(2, 6, (unsigned long)(Temp * 10000) % 10000, 4);//小数部分
    }
}